package com.movitech.mobile.cz.base.purchase.threadlocal;

import com.movitech.mobile.cz.base.purchase.entity.WFlowFormSteps;
import org.apache.commons.collections.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

public class ThreadLocalWFlowFormSteps {

	private static ThreadLocalWFlowFormSteps instance;
	private ThreadLocalWFlowFormSteps(){

	}
	public static ThreadLocalWFlowFormSteps getInstance(){
		if(instance==null){
			instance=new ThreadLocalWFlowFormSteps();
		}
		return instance;
	}
	public   ThreadLocal<List<WFlowFormSteps>> threadLocal = new ThreadLocal<List<WFlowFormSteps>>();

	public List<WFlowFormSteps> getItem(){
		return threadLocal.get();
	}
	
	public void setItem(WFlowFormSteps wFlowFormSteps) {
		List<WFlowFormSteps> lstWFlowFormSteps = threadLocal.get();
		if(CollectionUtils.isEmpty(lstWFlowFormSteps)) {
			lstWFlowFormSteps = new ArrayList<WFlowFormSteps>();
			lstWFlowFormSteps.add(wFlowFormSteps);
			threadLocal.set(lstWFlowFormSteps);
		}else {
			lstWFlowFormSteps.add(wFlowFormSteps);
		}
	}
	public void remove(){
		this.threadLocal.remove();
	}
}
